#include "stdio.h"

int seq_search(int array[], int n, int k, int seek_seq[]) {
    for (int i = 0; i < n; ++i) {
        seek_seq[i] = i;
        if (array[i] == k) {
            return 0;
        }
    }
    return -1;
};
int bin_search(int array[], int n, int k, int seek_seq[]) {
    int low = 0; int high = n - 1; int mid; int i = 0;
    while (high >= low) {
        mid = (low + high) / 2;
        seek_seq[i] = mid;
        if (array[mid] == k) {
            return 0;
        }
        else if (array[mid] > k) {
            high = mid - 1;
        }
        else {
            low = mid + 1;
        }
        i++;
    }
    return -1;
};
int main() {
    int array[] = { 1,2,7,8,13,55,59,420 };
    int n = sizeof(array) / sizeof(array[0]);
    int seek_sek[n];
    for (int i = 0; i < n; ++i) {
        seek_sek[i] = -1;
    }
    bin_search(array, n, 1, seek_sek);
    for (int i = 0; i < n; ++i) {
        printf("%d\t", seek_sek[i]);
    }
    return 0;
}